package com.songcha.library_common.util

import android.util.Log
import com.songcha.library_common.BuildConfig
import com.songcha.library_common.LibraryCommon
import java.lang.StringBuilder

object LogUtil {
    @JvmStatic
    private fun getLogStr(msgs:Array<Any>):String{
        if(!BuildConfig.DEBUG) return ""

        val sb=StringBuilder()
        for(i in msgs.indices){
            var m=msgs[i]
            sb.append(m)
            if(i!=msgs.size-1)
                sb.append(",")
        }
        var str=sb.toString()
        return str
    }

    @JvmStatic
    fun log(vararg msgs:Any?,tag:String="debug"){
        val str=getLogStr(msgs as Array<Any>)
        if(str != "")
            Log.i(tag,str)

    }

    @JvmStatic
    fun logD(vararg msgs:Any?,tag:String="debug"){
        val str=getLogStr(msgs as Array<Any>)
        if(str != "")
            Log.d(tag,str)
    }

    @JvmStatic
    fun logE(vararg msgs:Any?,tag:String="debug"){
        val str=getLogStr(msgs as Array<Any>)
        if(str != "")
            Log.e(tag,str)
    }

    @JvmStatic
    fun logV(vararg msgs:Any?,tag:String="debug"){
        val str=getLogStr(msgs as Array<Any>)
        if(str != "")
            Log.v(tag,str)
    }

    @JvmStatic
    fun logW(vararg msgs:Any?,tag:String="debug"){
        val str=getLogStr(msgs as Array<Any>)
        if(str != "")
            Log.w(tag,str)
    }
}